<?php

/**
 * File Name：Callback.php
 * File Encoding：UTF-8
 * File New Time：2014-6-4 14:44:23
 * Author：水平凡
 * Mailbox：admin@abc3210.com
 */
class Callback {

    //订单数据
    protected $data = '';

    /**
     * 链接回调服务
     * @staticvar null $handier
     * @return \Callback
     */
    static public function getInstance($payment_types) {
        static $handier = NULL;
        if (empty($handier)) {
            if (empty($payment_types)) {
                $handier = new Callback();
            }
            $data = MoneyPositionModel::model()->findByPk($payment_types);
            if (empty($data)) {
                $handier = new Callback();
            }
            Yii::import('ext.alipay.Callback.*');
            $class = $data->callback;
            if (class_exists($class)) {
                $handier = new $class();
            }
        }
        return $handier;
    }

    public function __get($name) {
        if (isset($this->data[$name])) {
            return $this->data[$name];
        }
    }

    /**
     * 设置数据
     * @param type $data
     * @return \Callback
     */
    public function data($data) {
        $this->data = $data;
        return $this;
    }

    /**
     * 执行回调
     * @return boolean
     */
    public function run() {
        return true;
    }

}
